package com.zhao.deepClone.useCloneMethod.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Person implements Cloneable {

    private String name;

    private Dog pet;

    @Override
    public Object clone(){
        Person clone = null;
        try {
            //克隆了普通变量与string类型
            clone = (Person) super.clone();
            clone.setPet((Dog) pet.clone());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return clone;
    }
}
